package com.worktest.test.tests.controller;

import com.worktest.test.tests.entity.User;
import com.worktest.test.tests.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/add")
    public void addUser(User user) {
        userService.addUser(user);
    }

    @RequestMapping("/del/{id}")
    public void delUser(@PathVariable Integer id){
        userService.delUser(id);
    }

    @RequestMapping("/update")
    public void updateUser(User user){
        userService.updateUser(user);
    }

    @RequestMapping("/findOne/{id}")
    public User findOne(@PathVariable Integer id){
        return userService.findOne(id);
    }

    @RequestMapping("/findAll")
    public List<User> findAllUser(){
        return userService.findAllUser();
    }
}
